<template>
	<view class="wraper">
		<view class="timer" @click="enterIndex()">
			<text>{{count}}</text>
			<text class="seconed"> S</text>
		</view>
		
		<u--image  bgColor="#000000" width="100%" height="100%"  class="pageImg" :src="imgUrl" mode="aspectFill">
			<u-loading-icon  size="36"slot="loading"></u-loading-icon>
 		</u--image>
		<button @click="toLink()" class="button">点击查看详情</button>
	</view>
</template>

<script>
	const app = getApp();
	const util = require('@utils/util.js');
	const network = require('@manager/network-manager.js');
	const timeSecond = 5;
	export default {
		data() {
			return {
				imgUrl:'',
				info:[],
				timer:-1,
				count:5
			}
		},
		created(){
			this.getHomeList()
		},
		
		methods: {
			toLink(){
				clearTimeout(this.timer)
				this.timer = -1;
				
				if(this.info && this.info.toTypeDicId && this.info.toTypeDicId!='0'){
					// console.log("bannerJump"+JSON.stringify(this.info));
					util.bannerJump(this.info)
				}else{
					console.log("enterIndex");
					this.enterIndex();
				}
			},
			enterIndex(){
				clearInterval(this.timer)
				this.timer = -1
				uni.switchTab({
					url:'/pages/community/community'
				})
			},
			getHomeList: function() {
				var that = this;
				
				
				// var uri = app.$config.interfaces.URL_HOME_GET_HOME_LIST;
				var uri = app.globalData.config.BASE_URL + app.globalData.config.interfaces.URL_HOME_GET_HOME_LIST
				var isSource = 2
				
				
				
				//#ifdef MP-WEIXIN
				isSource = 1
				//#endif
				var params = {
					"isfrom": isSource,
					"position": 3,
					"statusFlag":0
				};
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						console.log(res)
						if(res.data[0].image){
							that.imgUrl = res.data[0].image
							that.info = res.data[0]
							that.count = timeSecond;
							that.timer = setInterval(function(){
								that.count --
								if(that.count == 0){
									clearInterval(that.timer)
									that.timer = -1
									that.enterIndex()
								}
							},1000)
						}else{
							that.enterIndex()
						}
					} else {
						that.enterIndex()
					}
				}).catch(res => {
					that.enterIndex()
				});
			},
		}
	}
</script>
<style>
	page{
		background-color: black;
	}
</style>
<style scoped>
	.seconed{
		font-size: 20upx;
	}
.timer{
	position: absolute;
	width: 80upx;
	height: 80upx;
	right: 60upx;
	top: 80upx;
	
	background: rgba(0, 0, 0, 0.3);
	border-radius: 80upx;
	z-index: 99;
	text-align: center;
	line-height: 80upx;
	color: #ffffff;
	background-color: #333333;
}
.wraper{
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	position: relative;
	background-color: #000000;
}
.button{
	position: absolute;
	width: 80%;
	bottom: 50px;
	left: 10%;
	height: 84upx;
	line-height: 84upx;
	font-family: 'PingFang SC';
	font-style: normal;
	font-weight: 400;
	font-size: 16px;

	border: 2upx solid #FFFFFF;
	color: #FFFFFF;
	background: transparent;
	border-radius: 4upx;
}
.wraper .pageImg{
	width: 100%;
	height: 100%;
	
}
</style>
